package com.ktjy.filter;


import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @author lqm
 * @ClassName WebFilter
 * @description: TODO
 */
public class WebFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        HttpServletRequest request= (HttpServletRequest) servletRequest;
//        HttpServletResponse response = (HttpServletResponse) servletResponse;
//        HttpSession session = request.getSession();
//       String urlStr= request.getRequestURL().toString();
//        //判断当前是否已登录？
//        if(session.getAttribute("loginUser")==null){
//
//            response.sendRedirect("/");
//        }else{
//            if(urlStr.equals("/login")){
                filterChain.doFilter(servletRequest, servletResponse);
//            }else{
//                response.sendRedirect("/403");
//            }
//
//
//        }
    }

    @Override
    public void destroy() {

    }
}
